<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('作业管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12">
            <div class="wrapper wrapper-content animated fadeInRight ibox-content">
                <div class="tabs-container">
                <ul class="nav nav-tabs">
                    <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 定时作业</a>
                    </li>
                    <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">异步作业</a>
                    </li>
                    <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="true"> 挂起作业</a>
                    </li>
                    <li class=""><a data-toggle="tab" href="#tab-4" aria-expanded="false">死亡作业</a>
                    </li>
                </ul>
                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="panel-body">
                            <div class="col-sm-12 search-collapse">
                                <form id="formId">
                                    <div class="select-list">
                                        <ul>
                                            <li>
                                                流程定义ID：<input type="text" name="processDefinitionId">
                                            </li>
                                            <li class="select-time">
                                                <label style="width: 100px">计划执行时间：</label>
                                                <input style="width: 150px" type="text" class="time-input" id="startDate1" placeholder="开始时间"  name="startDate"/>
                                                <span>-</span>
                                                <input style="width: 150px" type="text" class="time-input" id="endDate1" placeholder="结束时间" name="endDate"/>
                                            </li>
                                            <li>
                                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('formId', 'timerjob' )"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('formId', 'timerjob')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                            </li>
                                        </ul>
                                    </div>
                                </form>
                            </div>
                            <div class="col-sm-12 select-table table-striped">
                                <table id="timerjob"></table>
                            </div>
                        </div>
                    </div>
                    <div id="tab-2" class="tab-pane">
                        <div class="panel-body">
                                <div class="col-sm-12 search-collapse">
                                    <form id="form2">
                                        <div class="select-list">
                                            <ul>
                                                <li>
                                                    流程定义ID：<input type="text" name="processDefinitionId">
                                                </li>
                                                <li class="select-time">
                                                    <label style="width: 100px">计划执行时间：</label>
                                                    <input style="width: 150px" type="text" class="time-input" id="startDate2" placeholder="开始时间"  name="startDate"/>
                                                    <span>-</span>
                                                    <input style="width: 150px" type="text" class="time-input" id="endDate2" placeholder="结束时间" name="endDate"/>
                                                </li>
                                                <li>
                                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('form2', 'job' )"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('form2', 'job')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </form>
                                </div>
                            <div class="col-sm-12 select-table table-striped">
                                <table id="job"></table>
                            </div>
                        </div>
                    </div>
                    <div id="tab-3" class="tab-pane">
                        <div class="panel-body">
                                <div class="col-sm-12 search-collapse">
                                    <form id="form3">
                                        <div class="select-list">
                                            <ul>
                                                <li>
                                                    流程定义ID：<input type="text" name="processDefinitionId">
                                                </li>
                                                <li>
                                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('form3', 'suspendjob' )"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('form3', 'suspendjob')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </form>
                                </div>
                            <div class="col-sm-12 select-table table-striped">
                                <table id="suspendjob"></table>
                            </div>
                        </div>
                    </div>
                    <div id="tab-4" class="tab-pane">
                        <div class="panel-body">
                                <div class="col-sm-12 search-collapse">
                                    <form id="form4">
                                        <div class="select-list">
                                            <ul>
                                                <li>
                                                    流程定义ID：<input type="text" name="processDefinitionId">
                                                </li>
                                                <li class="select-time">
                                                    <label style="width: 100px">计划执行时间：</label>
                                                    <input style="width: 150px" type="text" class="time-input" id="startDate4" placeholder="开始时间"  name="startDate"/>
                                                    <span>-</span>
                                                    <input style="width: 150px" type="text" class="time-input" id="endDate4" placeholder="结束时间" name="endDate"/>
                                                </li>
                                                <li>
                                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('form4', 'deadjob' )"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('form4', 'deadjob')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </form>
                                </div>
                            <div class="col-sm-12 select-table table-striped">
                                <table id="deadjob"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            </div>
        </div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "flow/monitor";

    $(function() {
        var options = {
            id: "timerjob",
            url: prefix + "/listJobs?type=1",
            modalName: "定时作业",
            columns: [
                {
                    field: 'processDefinitionId',
                    title: '流程定义编号',
                    visible: true
                },
                {
                    field: 'jobHandlerType',
                    title: '作业类型'
                },
                {
                    field: 'duedate',
                    title: '计划执行时间'
                },
                {
                    field: 'processInstanceId',
                    title: '流程实例编号'
                },
                {
                    field: 'retries',
                    title: '剩余重试次数'
                }]
        };
        $.table.init(options);

        var joboptions = {
            id: "job",
            url: prefix + "/listJobs?type=2",
            modalName: "异步作业",
            columns: [
                {
                    field: 'processDefinitionId',
                    title: '流程定义编号',
                    visible: true
                },
                {
                    field: 'jobHandlerType',
                    title: '作业类型'
                },
                {
                    field: 'duedate',
                    title: '计划执行时间'
                },
                {
                    field: 'processInstanceId',
                    title: '流程实例编号'
                },
                {
                    field: 'retries',
                    title: '剩余重试次数'
                }]
        };
        $.table.init(joboptions);

        var suspendoptions = {
            id: "suspendjob",
            url: prefix + "/listJobs?type=3",
            modalName: "挂起作业",
            columns: [
                {
                    field: 'processDefinitionId',
                    title: '流程定义编号',
                    visible: true
                },
                {
                    field: 'jobHandlerType',
                    title: '作业类型'
                },
                {
                    field: 'duedate',
                    title: '计划执行时间'
                },
                {
                    field: 'processInstanceId',
                    title: '流程实例编号'
                },
                {
                    field: 'retries',
                    title: '剩余重试次数'
                }]
        };
        $.table.init(suspendoptions);

        var deadoptions = {
            id: "deadjob",
            url: prefix + "/listJobs?type=4",
            modalName: "死亡作业",
            columns: [
                {
                    field: 'processDefId',
                    title: '流程定义编号',
                    visible: true
                },
                {
                    field: 'jobHandlerType',
                    title: '作业类型'
                },
                {
                    field: 'dueDate',
                    title: '计划执行时间'
                },
                {
                    field: 'processInstanceId',
                    title: '流程实例编号'
                },
                {
                    field: 'exceptionMessage',
                    title: '剩余重试次数',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                }]
        };
        $.table.init(deadoptions);

        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: '#startDate1',
                type: 'datetime',
                trigger: 'click'
            });

            laydate.render({
                elem: '#endDate1',
                type: 'datetime',
                trigger: 'click'
            });

            laydate.render({
                elem: '#startDate2',
                type: 'datetime',
                trigger: 'click'
            });

            laydate.render({
                elem: '#endDate2',
                type: 'datetime',
                trigger: 'click'
            });

            laydate.render({
                elem: '#startDate4',
                type: 'datetime',
                trigger: 'click'
            });

            laydate.render({
                elem: '#endDate4',
                type: 'datetime',
                trigger: 'click'
            });
        });


    });
</script>
</body>
</html>